package com.vshop.controller.aspecial;

import com.vshop.config.dto.ResultDataDto;
import com.vshop.entity.aspecial.activate.request.RequestFirstOrder;
import com.vshop.entity.aspecial.activate.response.ResponseFirstOrder;
import com.vshop.entity.aspecial.order.request.RequestAccessOrder;
import com.vshop.entity.aspecial.order.response.ResponseAccessOrder;
import com.vshop.entity.aspecial.querydevice.request.RequestQueryDevice;
import com.vshop.entity.aspecial.querydevice.response.ResponseQueryDevice;
import com.vshop.entity.aspecial.queryorder.request.RequestSpecialQueryOrder;
import com.vshop.entity.aspecial.queryorder.response.ResponseSpecialQueryOrder;
import com.vshop.service.aspecial.SpecialLogicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 大阳相关的所有接口
 * <p>
 * 1,设备实时信息查询接口。
 * 说明：接口响应中返回卡片归属的标识，卡片是否有历史订单，有订单的话的预计到期时间，剩余天数等。
 * <p>
 * 2,激活领科卡片接口。（激活免费赠送的1年套餐）
 * 说明：接口1中响应为领科卡且为首次绑定商用套餐，对接此接口无支付流程为领科卡片订购套餐。
 * <p>
 * 3,卡片订购套餐接口。
 * 说明：接口1中响应为领科卡且不是首次绑定商用套餐，或者响应为非领科卡。此接口将返回一个url地址，前端即可打开H5商城订购套餐。
 * <p>
 * 4,支付订单同步接口。
 * 说明：同步用户在H5中的支付订单给大阳，用于给用户展示订单记录。
 *
 * @author lm
 * @date 2020/8/11 15:54
 */
@RestController
@Api(value = "大阳相关的接口")

public class DaYangController {

    @Autowired
    SpecialLogicService logicService;

    /**
     * 设备实时信息查询接口:
     * <p>
     * 1，接口响应将返回卡片是否归属领科
     * <p>
     * 2，接口响应将返回卡片接下来是应该走订购的接口还是激活的接口
     * <p>
     * 返回格式是：{"data":{},"message":"string","operateCode":"string"},ResponseQueryDevice是data部分
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "queryDevice", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "查询设备信息接口", response = ResponseQueryDevice.class)
    public ResultDataDto queryDevice(@ApiParam @RequestBody RequestQueryDevice request) {
        return logicService.queryDevice(request);
    }

    /**
     * 订购套餐接口：
     * <p>
     * 1，领科卡片非首次订购套餐
     * <p>
     * 2，非领科卡片无论第几次代收服务费都叫订购套餐
     * <p>
     * 3，有支付的过程
     * <p>
     * 4，非领科卡片套餐是固定的。
     * <p>
     * 5，领科卡片还是按照现有逻辑订购
     * <p>
     * 返回格式是：{"data":{},"message":"string","operateCode":"string"},ResponseAccessOrder是data部分
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "topUp", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "充值订购套餐接口", response = ResponseAccessOrder.class)
    public ResultDataDto topUp(@ApiParam @RequestBody RequestAccessOrder request) {
        return logicService.topUp(request);
    }

    /**
     * 激活接口：
     * <p>
     * 领科出卡只带一个赠送套餐首次来订购我们把这种情况定义为卡片激活:
     * <p>
     * 1，访问此接口直接异步为卡片订购套餐
     * <p>
     * 2，没有支付的过程
     * <p>
     * 3，套餐是固定的，是否需要给它做成动态的套餐。
     * <p>
     * 返回格式是：{"data":{},"message":"string","operateCode":"string"},ResponseFirstOrder是data部分
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "activate", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "激活卡片接口", response = ResultDataDto.class)
    public ResultDataDto activate(@ApiParam @RequestBody RequestFirstOrder request) {
        return logicService.activate(request);
    }


    /**
     * 查询设备的订单接口：
     * <p>
     * 1，领科卡片用接口去北京查询
     * <p>
     * 2，非领科卡片在深圳的数据库里面匹配
     * <p>
     * 3，两种卡片的订单信息尽量参数要做到统一
     * <p>
     * 返回格式是：{"data":{},"message":"string","operateCode":"string"},ResponseSpecialQueryOrder是data部分
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "queryOrder", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "查询设备的订单接口", response = ResponseSpecialQueryOrder.class)
    public ResultDataDto queryOrder(@ApiParam @RequestBody RequestSpecialQueryOrder request) {
        return logicService.queryOrder(request);
    }

}
